<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%@taglib prefix="s" uri="/struts-tags"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://"
			+ request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>发送彩信</title>
<script type='text/javascript' src='js/jquery-1.4.2.min.js'></script>
<script type='text/javascript' src='js/jquery.validate.min.js'></script>
<script type='text/javascript' src='js/common.js'></script>
<script type='text/javascript' src='js/jquery-ui-1.7.3.custom.min.js'></script>  
 <link href="style/ui-lightness/jquery-ui-1.7.3.custom.css" rel="stylesheet" type="text/css">
<link href="manage/manage.css" rel="stylesheet" type="text/css">
<link href="style/css.css"  rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
a:link {
	text-decoration: none;
}
a:visited {
	text-decoration: none;
}
a:hover {
	text-decoration: none;
}
a:active {
	text-decoration: none;
}
.STYLE13 {color: #A3A3A3}


-->
</style>
<SCRIPT type="text/javascript">
	function clean() {
		$("#sendForm").attr("action", "msg!cleanReceive.action");
		$("#sendForm").submit();
	}

	function edit() {
		$("#editTxtError").text("");
		$("#editTxtDiv").dialog('open');
	}

	function init() {
		   var dialogOpts = {
			 	   title:"号码编辑",
			 	  draggable:false,
			 	 resizable:false,
			 	 width: 350,
			 	autoOpen: false,
		 		   buttons: {
		 		      "Ok": function() {
					    	if ($.trim($("#editTxtContent").val()) == "") {
					    		$("#editTxtError").text("请输入接收者号码");
						    	return false;
					    	}
					    	$("#editTxtContent2").val($("#editTxtContent").val());
					    	$("#sendForm").attr("action", "msg!editTxt.action");
					    	$("#sendForm").submit();
				       } 
		 		   }
		 		};
		 	$("#editTxtDiv").dialog(dialogOpts);
	   }

	   function yulan(id) {
		   if ($("#txtedit") != null) {
			   $("#yulanTxt").val($("#txtedit").val()); 
		   }
		   $("#yulanTitle").val($("#likeName").val()); 
		   $("#yulanForm").attr("action", "mobanListAction!yulan.action?fasongYulan=1&id=" + id);
		   $("#yulanForm").submit();
	   }

	   function send() {
		   if($.trim($("#likeName").val()) == "") {
			   $("#formError").text("请输入标题");
			   return;
		   }
		   if (!$("#txtedit")) {
			   if ($("#txtedit").val().length>1000) {
				   return;
			   }
			   if($.trim($("#txtedit").val()) == "") {
					$("#formError").text("");
			   }
		   }
		   $("#sendForm").submit();		   
	   }

	   function syContent() {
		   var l = $("#txtedit").val().length;
		   $("#contentLimitTips").text("(" + l+ "/1000)最多可输入1000字");
		   if(l > 1000) {
			  //$("#contentLimitTips").css("color","red");
				$("#txtedit").val($("#txtedit").val().substr(0, 1000));
		   } else {
			 //  $("#contentLimitTips").css("color","black");
			   $("#preViewTxt").val($("#txtedit").val());
		   }
	   }

	   function uploadSender() {
		   if ($("#receice").val()=="") {
			   $("#formError").text("请选择要上传的文件");
			   return false;
		   }  
		   $("#sendForm").attr("action", "msg!uploadReceive.action");
		   $("#sendForm").submit();
	   }

	   function checkContextNumber(el) {
		   if (event.keyCode == 8 ) {
			   return true;
		   }
		   if(el.value.length >= 1000) {
			      event.returnValue = false; 
		   }
	   }

	   
</SCRIPT>

</head>
<body style="margin:0px; text-align:center;" onLoad="parent.document.all.iHeight.height=this.document.body.scrollHeight+10;"  bgcolor="#F1F1F1" >
<s:form name="sendForm" id="sendForm" action="msg!sendMsg.action" enctype="multipart/form-data" method="post">
<textarea style="display: none;" rows="20" cols="50" name="receiceStr"  id="editTxtContent2"></textarea>
<table width="789" height="715" border="0" cellpadding="0" cellspacing="0" bgcolor="#F1F1F1">
  <tr>
    <td width="789" height="39" align="left" valign="middle"><span class="STYLE1">&nbsp;<a href="javascript:void(parent.window.location.href='loginAction!login.action')" class="STYLE1">我的易彩通</a> &gt; 发送彩信</span></td>
  </tr>
  <tr>
    <td height="676" align="center" valign="top" bgcolor="#FFFFFF" style="border:1px solid #C5C5C5; padding:1px ;"><table width="100%" height="32" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="1%" height="32" background="images/sp_bg.jpg">&nbsp;</td>
        <td width="3%" align="center" background="images/sp_bg.jpg" style="border-bottom:1px solid #C5C5C5;"><img src="images/dian.jpg" width="10" height="16" /></td>
        <td width="95%" align="left" background="images/sp_bg.jpg" style="border-bottom:1px solid #C5C5C5;"><span class="STYLE3">发送彩信</span></td>
        <td width="1%" background="images/sp_bg.jpg">&nbsp;</td>
      </tr>
    </table>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="8">&nbsp;</td>
        </tr>
      </table>
      
      <table width="775" height="613" border="0" cellpadding="0" cellspacing="0">
        <tr>
          <td width="370" height="613" align="center"><table width="261" height="552" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td height="99" colspan="3"><img src="images/sj_top.jpg" width="286" height="99"></td>
            </tr>
            <tr>
              <td width="24" height="357"><img src="images/sj_left.jpg" width="24" height="359"></td>
              <td width="240" valign="top"><table width="239" style="border:1px solid #AFAFAF;" height="359" border="0" cellpadding="0" cellspacing="0">
                  <tr>
                    <td>
                    	<s:if test="mubanMsg.manageMsgDetails ==null || mubanMsg.manageMsgDetails.size()==0 || mubanMsg.manageMsgDetails[0]==null || mubanMsg.manageMsgDetails[0].pic == null || mubanMsg.manageMsgDetails[0].pic ==''">
							<img   title="1" width="240" height="195" src="images/default_msg_pic.jpg"  />
						</s:if>
						<s:else>
								<img  title="2" width="240" height="195" src="<s:property value="mubanMsg.manageMsgDetails[0].pic"/>" />
						</s:else>
                    </td>
                  </tr>
                  
                  <s:if test="#session.msg_txt_tmp == null || #session.msg_txt_tmp==''">
	                  <tr>
	                    <td height="159"><textarea  readonly="readonly" name="grjj2" cols="30" rows="8" id="preViewTxt" style="border:0px; height:157px; width:236px; color:#636363; line-height:18px; letter-spacing:1px; font-size:12px;">姓名：${session.userObject.userName} 
所在地区：${session.userObject.province}${session.userObject.city}${session.userObject.zone} 
所在公司：${session.userObject.company.companyName}
手机号码：${session.userObject.account}
电子邮箱：${session.userObject.email}
QQ号码：${session.userObject.qq}
个人主页：${session.userObject.personalHonepage}
个人介绍：${session.userObject.personalIntro}</textarea></td>
	                  </tr>
                  </s:if>
                  <s:else>
                  		<tr>
	                    <td height="159"><textarea readonly="readonly" name="grjj2" cols="30" rows="8" id="preViewTxt" style="border:0px; height:157px; width:236px; color:#636363; line-height:18px; letter-spacing:1px; font-size:12px;">${session.msg_txt_tmp}</textarea></td>
	                  </tr>
                  </s:else>
                  
              </table></td>
              <td width="22"><img src="images/sj_right.jpg" width="22" height="359"></td>
            </tr>
            <tr>
              <td height="96" colspan="3"><img src="images/sj_end.jpg" width="286" height="96"></td>
            </tr>
          </table></td>
          <td width="405" align="left" valign="top"><table width="371" height="460" border="0" cellpadding="0" cellspacing="0">
            <tr>
              <td width="79" height="75" align="right">&nbsp;</td>
              <td colspan="4">&nbsp;</td>
            </tr>
            <tr>
              <td height="51" align="right"><img src="images/jq.jpg" width="31" height="32">&nbsp;&nbsp;</td>
              <td colspan="4" class="STYLE12"><strong>你的账号余额为：${session.userObject.msgCnt}条</strong> <a href="pay.jsp" class="di_ys">在线充值</a></td>
            </tr>
            <tr>
              <td>&nbsp;</td>
              <td colspan="4">&nbsp;</td>
            </tr>
            <tr>
              <td height="30" align="right">彩信标题： </td>
              <td colspan="4">
              	<s:textfield name="likeName" id="likeName" value="%{mubanMsg.title}"></s:textfield>
              </td>
            </tr>
            <!-- 可以编辑就多出个编辑框 -->
            <s:if test="mubanMsg.bisType.editAble==1">
            <tr>
              <td height="30" align="right" valign="top">文字内容：</td>
              <td colspan="4" align="left" valign="top"  >
              <s:textarea name="txt" onkeydown="checkContextNumber(this);" onkeyup="syContent();" id="txtedit" cols="40" rows="5" value="%{#session.msg_txt_tmp}"></s:textarea>
              </td>
            </tr>
            <tr>
            	<td>&nbsp;</td>
            	<td colspan="4"><div id="contentLimitTips"></div></td>
            </tr>
            </s:if>
            
            <tr>
              <td height="29" align="right" nowrap="nowrap">末页内容：</td>
              <td colspan="4">我的名片</td>
            </tr>
            <tr>
              <td height="47">&nbsp;</td>
              <td colspan="4">&nbsp;</td>
            </tr>
            <tr>
              <td height="39" align="right" nowrap="nowrap">彩信接收者(txt文件)：</td>
              <td  align="left">
              	<input type="file" name="receice" id="receice" cssClass="filesc" contenteditable="false"/>
               </td>
              <td   colspan="3"  align="left" nowrap="nowrap">
              	<a href="javascript:void(uploadSender())">&nbsp;<img src="images/shangchuan.jpg" title="上传" width="42" height="21" border="0"></a>
              	<a href="javascript:clean();"><img src="images/qc.jpg" title="清除" width="42" height="21" border="0"></a>
               <a href="javascript:edit();"><img title="编辑" src="images/bj.jpg" width="42" height="21" border="0" onClick="open1('cxbj.html')"></a>
              </td>
            </tr>
            <tr>
              <td height="37" align="right" nowrap="nowrap">接收号码数： </td>
              <td colspan="4" align="left" class="STYLE13">
              <s:if test="#session.msg_receives == null">0</s:if>
              <s:else><s:property value="#session.msg_receives.size()"/> </s:else>
              &nbsp;(不得大于3000)</td>
            </tr>
            <tr>
              <td height="78">&nbsp;</td>
              <td colspan="4"><a href="javascript:yulan(${mubanMsg.id });"><img src="images/yl.jpg" width="92" height="24" border="0"></a> <a href="javascript:send();"><img src="images/ts.jpg" width="92" height="24" border="0"></a></td>
            </tr>
            <tr>
            <td>&nbsp;</td>
              <td height="62" colspan="4" style="line-height:23px"><div align="left" class="STYLE13">请避免在晚上21：00以后至早上9：00之前发送彩信<br>
                              批量发送时请单条测试。</span> </td>
              </tr>
             <tr>
             	<td>&nbsp;</td>
             	<td colspan="4">
             		<div id="formError" style="color: red;"></div>
             	</td>
             </tr>
             <s:if test="hasErrors()">
             <tr>
             	<td>&nbsp;</td>
             	<td colspan="4" style="color: red;" align="center">
             	<div align="left">
             		<s:actionerror/>
             	</div>
             	</td>
             </tr>
             </s:if>
          </table></td>
        </tr>
      </table></td>
  </tr>
</table>
<table width="200" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td height="8">&nbsp;</td>
  </tr>
</table>

<table width="792" height="220" border="0" cellpadding="0" cellspacing="0" bgcolor="#F1F1F1">

  <tr>
    <td height="220" align="center" valign="top" bgcolor="#FFFFFF" style="border:1px solid #C5C5C5; padding:1px ;"><table width="100%" height="32" border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td width="1%" height="32" background="images/sp_bg.jpg">&nbsp;</td>
        <td width="3%" align="center" background="images/sp_bg.jpg" style="border-bottom:1px solid #C5C5C5;"><img src="images/dian.jpg" width="10" height="16" /></td>
        <td width="94%" align="left" background="images/sp_bg.jpg" style="border-bottom:1px solid #C5C5C5;"><span class="STYLE3">还可能发送</span></td>
        <td width="2%" align="left" background="images/sp_bg.jpg">&nbsp;</td>
      </tr>
    </table>
      <table width="100%" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="8">&nbsp;</td>
        </tr>
      </table>
      
     <table width="748" border="0" cellpadding="0" cellspacing="0">
<div id="images">
<tr >
<td width="40" height="85" align="center"><p ><img onclick="javascript:window.location.href='msg!sendPage.action?first=1&mubanId=${mubanMsg.id}';" style="cursor:hand;" src="images/left1.jpg" width="24" height="24"></p></td>
<s:iterator value="randonMsgs" status="st" id="msg">
<td width="153" align="left">
	<div align="left">
		<div>
		<s:if test="#msg.manageMsgDetails ==null || #msg.manageMsgDetails.size()==0 || #msg.manageMsgDetails[0]==null || #msg.manageMsgDetails[0].pic == null || #msg.manageMsgDetails[0].pic ==''">
			<img src="images/default_msg_pic.jpg"  style="height: 106px;width: 126px;" />
		</s:if>
		<s:else>
				<img src="<s:property value="#msg.manageMsgDetails[0].pic"/>"   style="height: 106px;width: 126px;"/>
		</s:else>
		</div>
		
		<div>${msg.title}</div>
		<div style="height: 35px;text-align: right;margin-right: 10px;">
			  <s:if test="#session.userObject != null">
			                    			<s:if test="#request.typeObj.id==8">
			                    				<a href="msg!sendPage.action?first=1&mubanId=${msg.id}"  >发送</a>&nbsp;&nbsp;&nbsp;&nbsp;
			                    			</s:if>
			                    			<s:elseif test="#session.userObject.type==1">
			                    				<a href="msg!sendPage.action?first=1&mubanId=${msg.id}"  >发送</a>&nbsp;&nbsp;&nbsp;&nbsp;
			                    			</s:elseif>
			                    		</s:if>
			  			<a href="mobanListAction!yulan.action?id=${msg.id }" target="_blank">预览</a>&nbsp;&nbsp;&nbsp;&nbsp;
		</div>
	</div>
</td>
</s:iterator>

<td width="40" align="right"><p><img onclick="javascript:window.location.href='msg!sendPage.action?first=1&mubanId=${mubanMsg.id}';" src="images/right1.jpg" width="24" height="24" style="cursor:hand;"></p></td>
</tr>
</div>
</table>
    </td>
  </tr>
</table>

</s:form>

<!-- 编辑彩信的div -->
<div id="editTxtDiv" style="display: none;">&nbsp;
	<div>
		<textarea rows="20" cols="50" name="receiceStr"  id="editTxtContent"><s:iterator value="#session.msg_receives" status="st" id="r">${r}
</s:iterator></textarea>
	</div>
	<div>注意：接收者号码列表是由每行一个号码加回车组成</div>
	<div style="color: red;" id="editTxtError"></div>
</div>


<s:form name="yulanForm" id="yulanForm" action="msg!yulan.action?fasongYulan=1" method="post" target="_blank">
	<input type="hidden" name="txt" id="yulanTxt"/>
	<input type="hidden" name="likeName" id="yulanTitle"/>
</s:form>
<SCRIPT type="text/javascript">
init();
syContent();
</SCRIPT>
</body>
